package com.xuanmiao.smsback.service.platform.operator.impl;

import com.xuanmiao.smsback.domain.qo.AreaContactInfoQO;
import com.panshi.hujin2.base.common.util.DozerUtils;
import com.panshi.hujin2.base.domain.page.Page;

import com.xuanmiao.smsback.dao.mapper.AreaContactInfoMapper;
import com.xuanmiao.smsback.dao.model.AreaContactInfoDO;

import com.xuanmiao.smsback.model.AreaContactInfoBO;
import com.xuanmiao.smsback.service.platform.operator.AreaContactInfoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;


@Service
public class AreaContactServiceImpl implements AreaContactInfoService {
    @Autowired
    private AreaContactInfoMapper areaContactInfoMapper;
    @Override
    public List<AreaContactInfoBO> getList(AreaContactInfoQO areaContactInfoQO) {
        if(areaContactInfoQO == null){
            areaContactInfoQO = new AreaContactInfoQO();
        }
        //获取运营商数量
        Integer count = areaContactInfoMapper.count(areaContactInfoQO);
        Page page = areaContactInfoQO.getPage();
        //设置总记录数
        page.setTotalNumber(count);
        List<AreaContactInfoDO> areaContactInfoDO = areaContactInfoMapper.queryAreaContactInfo(areaContactInfoQO);
        if(areaContactInfoDO!=null && areaContactInfoDO.size()>0){
            List<AreaContactInfoBO> areContactInfoBO = DozerUtils.convertList(areaContactInfoDO, AreaContactInfoBO.class);

            return areContactInfoBO;
                    //DozerUtils.convertList(areContactInfoMapper.query(areContactInfoQO),AreaContactInfoBO.class);
        }
        return Collections.emptyList();


    }

    @Override
    public AreaContactInfoBO getById(Integer id) {
        return DozerUtils.convert(areaContactInfoMapper.getById(id),AreaContactInfoBO.class);
    }

    @Override
    public void update(AreaContactInfoBO areContactInfoBO) {
        areaContactInfoMapper.update(DozerUtils.convert(areContactInfoBO,AreaContactInfoDO.class));

    }


}
